package UIFree.graphicTools.angle
{
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	import UIFree.uif_optionsComponent;
	
	import UIUtils.uif_util;
	
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class uif_radialLimb extends uif_optionsComponent {
		public function uif_radialLimb(parent:uif_component, ax:int=0, ay:int=0, asize:int=0, styleClass:Object='', a_options: Object=null) {
			super(parent, ax, ay, asize, asize, styleClass, a_options);
		}
		
		override protected function defaultOptions():Object {
			return {
				divs: [
					{
						count	: 24,
						size	: 0.08
					},{
						count	: 12,
						size	: 0.15
					}
				]
			}
		}
		
		override protected function paint(a_styleClass:String, a_method:String='draw_circle'):void {
			super.paint(a_styleClass, a_method);
			paintDivs();
		}
		
		protected function paintDivs(): void {
			var inner: Rectangle = getInner();
			var h2: Number = inner.height / 2;
			var c: Point = center
			for (var i: int=0; i<options.divs.length; i++) {
				var div: Object = options.divs[i];
				
				var p: Point = new Point(0, -h2);
				var p2: Point = new Point(0, div.size * h2 - h2);
				
				var mat: Matrix = new Matrix();
				mat.rotate(Math.PI/div.count * 2);
				for (var n: int=0; n<div.count; n++) {
					graphics.moveTo(c.x + p.x, c.y + p.y);
					graphics.lineTo(c.x + p2.x, c.y + p2.y);
					p = mat.transformPoint(p);					
					p2 = mat.transformPoint(p2);					
				}
			}
		}
	}
}